<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/18
 * Time: 12:53
 */

namespace backend\modules\qywx;

use Yii;
use yii\authclient\ClientInterface;
use yii\helpers\ArrayHelper;

class QywxAuthHandler
{

    /**
     * @var ClientInterface
     */
    private $client;

    /**
     * QywxAuthHandler constructor.
     * @param ClientInterface $client
     */
    public function __construct(ClientInterface $client)
    {
        $this->client = $client;
    }

    public function handle()
    {
        $attributes = $this->client->getUserAttributes();
        $userId = ArrayHelper::getValue($attributes, 'UserId');

//        /* @var Auth $auth */
//        $auth = Auth:: Auth::find()->where([
//            'source' => $this->client->getId(),
//            'source_id' => $id,
//        ])->one();

//        if (Yii::$app->user->isGuest) {//如果是未登录账号就处理添加账号
//
//        } else { // 已登录用户就与威信号绑定
//
//        }
    }
}